package com.xlh.common;

import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * 返回结果枚举类
 *
 * @author cheer
 */
public enum ResultEnum {

    SUCCESS(200, "请求成功"),

    // 通用异常
    BAD_REQUEST(400, "参数不合法"),
    UNAUTHORIZED(401, "用户未登录或已超时"),
    FORBIDDEN(403, "用户没有执行该请求的权限"),
    NOT_FOUND(404, "内容不存在"),
    SERVER_ERROR(500, "服务器内部错误"),
    SYSTEM_BUSY(1000, "系统繁忙，请稍后再试"),
    LICENSE_EXPIRE(2000, "License过期"),
    PROGRESS(3000, "进度展示"),

    // 删除处理异常
    DELETE_DEAL_EXCEPTION(501, "删除处理异常"),

    // 业务异常
    // 实验模块
    FILE_UPLOAD_ERROR(500106, "文件上传异常"),
    IMAGE_IS_ALLOCATED(500400, "镜像正在被使用，强制删除镜像会导致使用该镜像的容器、相关的镜像分配立即删除，请谨慎操作"),
    CHECK_ERROR(500401, "评测未通过"),

    // 用户模块
    LOGIN_FAILED(100100, "登录失败"),
    USER_INFO_MATCH_FAILED(100101, "用户名或密码错误"),
    VERIFICATION_CODE_ERROR(100102, "图形验证码错误"),
    ACCOUNT_NOT_EXIST(100103, "账号不存在"),
    ACCOUNT_EXPIRED(100104, "账号已过期"),
    USER_EXIST(100105, "用户已存在"),
    SMS_CODE_ERROR(100107, "短信验证码错误"),
    SMS_CODE_SEND_FAIL_ERROR(100108, "短信验证码发送频繁，请于%s分钟后重试"),

    // 课程
    COURSE_NOT_OWNER(100106, "当前课程不属于自己的课程"),
    CLASS_NOT_PASS(100109, "暂无审批记录"),

    // 导出excel
    EXCEL_OUTPUT_EXCEPTION(500600, "导出excel失败"),

    // 统计
    STATISTIC_LOCK_EXCEPTION(600100, "当前班级正在统计中，请稍后再试"),
    FILE_DOWNLOAD_ERROR(500700, "远程文件下载失败"),

    // 工程认证
    UNIQUE_NAME(700000, "达成度名称必须唯一"),
    NOT_FOUND_COURSE(700001, "未查询到当前关联课程"),
    NOT_FOUND_CONCLUDE(700002, "未查询到关联的目标"),
    NOT_FOUND_ClASS(700003, "未查询到关联的课程目标"),
    NOT_FOUND_CHECK(700005, "未查询到关联的考核项"),
    NOT_FOUND_CHECK_SUB(700005, "未查询到关联的考核分项"),
    NOT_FULL_WEIGHT(700004, "权重值之和未达到100%"),
    MORE_THEN_MAX_RECORD(700006, "考核项记录不能多于10条"),
    ERROR_FILE_TYPE(700007, "错误的文件类型"),
    NOT_MATCH_TEMPLATE(700008, "与模板头信息不匹配 请检查模板头信息！"),
    IS_EXIST_SNO(700009, "学生编号已存在"),
    NOT_FOUND_STUDENT_RECORD(700010, "未查询到关联的学生记录"),
    NOT_FOUND_DATA_INFO(7000011, "未查询到统计相关数据"),
    UPLOAD_FILE_FAILD(700012, "上传文件失败！"),
    UNIQUE_SUB_CHECK_NAME(700014, "考核分项名称必须唯一！"),
    UNIQUE_CHECK_NAME(700013, "考核项名称必须唯一！"),
    ERROR_RANGE_OF_THRESHOLD(700015, "阈值必须在 1~100 之间！"),
    ERROR_PRINCIPAL_IS_EMPTY(700015, "负责人名称不能为空!"),
    // 工程认证关联系统
    ERROR_COMPARE_FULL_MARK(700016, "缺勤扣减分不能大于考勤满分项！"),
    ERROR_COMPARE_DEGRESSION(700018, "缺勤扣减分不能为空！"),
    ERROR_COMPARE_MANIFESTSCORE(700019, "缺勤扣减分不能为空！"),
    ERROR_COMPARE_MORETHANZERO(700020, "分数请输入整数且必须大于0"),
    ERROR_FULL_MARK_CANTLESS_SCORE(700021, "满分项不能小于当前的最大得分！"),
    ERROR_FULL_MARK_THEN_SCORE(700022, "得分不得大于满分值 ！"),
    ERROR_FULL_MARK_NOT_NUMBER(700023, "满分值必须为正整数 ！"),
    ERROR_MUST_LESS_FULL_MARK(700024, "满分值必须小于200 且大于0！"),
    NOT_FOUND_REF_RECORD(700017, "未查询到关联记录！");


    private Integer code;

    private String message;

    ResultEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("code", code)
                .append("message", message)
                .toString();
    }
}
